//
//  OrderDetailViewController.m
//  LoveFreshBee
//
//  Created by brice Mac on 2016/10/20.
//  Copyright © 2016年 王忠迪. All rights reserved.
//

#import "OrderDetailViewController.h"

@interface OrderDetailViewController ()

@property(nonatomic,weak)UIImageView *bottom;

@end

@implementation OrderDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createTopView];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    UIImageView *iv = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-44)];
    iv.image = [UIImage imageNamed:@"orderDetail"];
    [self.tableView addSubview:iv];
    
    UIImageView *bottomView = [[UIImageView alloc]initWithFrame:CGRectMake(0, kScreenH-50, kScreenW, 50)];
    bottomView.image = [UIImage imageNamed:@"orderBottom"];
    _bottom = bottomView;
    [[UIApplication sharedApplication].keyWindow addSubview:bottomView];
}


- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    //从主窗上移除底部 ”bar“
    [self.bottom removeFromSuperview];
}

- (void)createTopView
{
    UISegmentedControl *topSegmentedControl = [[UISegmentedControl alloc]initWithFrame:CGRectMake(0 , 0, kScreenW/2, 30)];
    
    [topSegmentedControl insertSegmentWithTitle:@"订单状态" atIndex:0 animated:YES];
    [topSegmentedControl insertSegmentWithTitle:@"订单详情" atIndex:1 animated:YES];
    
    topSegmentedControl.tintColor = [UIColor colorWithRed:253 / 255.0 green:200 / 255.0 blue:8 / 255.0 alpha:1];
    
    
    topSegmentedControl.selectedSegmentIndex = 0;
    
    [topSegmentedControl addTarget:self action:@selector(changeView:) forControlEvents:UIControlEventValueChanged];
    
    [self.navItem setTitleView: topSegmentedControl];
    
}

- (void)changeView:(UISegmentedControl *)seg {
    
    NSInteger index = seg.selectedSegmentIndex;
    
    switch (index) {
        case 0:
//            self.tableViewUser.hidden = YES;
            break;
            
        case 1:
//            self.tableViewUser.hidden = NO;
            break;
            
        default:
            break;
    }
}


@end
